package org.javadatabasemigrations;

public class Version implements Comparable<Version> {

    private Integer version;


    public Version(final int version) {

        this.version = version;
    }


    public Integer getIntValue() {

        return version;
    }


    public boolean isHigherOrEqual(Version version) {

        return this.compareTo(version) >= 0;
    }


    @Override
    public boolean equals(final Object obj) {

        if (!Version.class.isAssignableFrom(obj.getClass())) {
            return false;
        }
        Version v = (Version) obj;
        return version.equals(v.getIntValue());
    }


    @Override
    public int hashCode() {

        return version.hashCode();
    }


    @Override
    public String toString() {

        return version.toString();
    }


    public int compareTo(Version o) {

        return getIntValue().compareTo(o.getIntValue());
    }

}
